﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
namespace MyWeb.Data
{
	public class tb_CustomerCareDAL : SqlDataProvider
	{

		#region[tb_CustomerCare_GetbyAll]
		public DataTable tb_CustomerCare_GetByAll()
		{
			using (var cmd = new SqlCommand("sp_tb_CustomerCare_GetByAll", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tb_CustomerCare_GetbyId]
		public DataTable tb_CustomerCare_GetById(tb_CustomerCareInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tb_CustomerCare_GetById", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@Id", Data.Id));
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tb_CustomerCare_GetbyTop]
		public DataTable tb_CustomerCare_GetByTop(string Top, string Where, string Order)
		{
			using (var cmd = new SqlCommand("sp_tb_CustomerCare_GetByTop", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				cmd.Parameters.Add(new SqlParameter("@Top",Top));
				cmd.Parameters.Add(new SqlParameter("@Where",Where));
				cmd.Parameters.Add(new SqlParameter("@Order",Order));
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tb_CustomerCare_Insert]
		public void tb_CustomerCare_Insert(tb_CustomerCareInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tb_CustomerCare_Insert", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Email", Data.UserName));
				cmd.Parameters.Add(new SqlParameter("@Title", Data.Title));
				cmd.Parameters.Add(new SqlParameter("@Content", Data.Content));
				cmd.Parameters.Add(new SqlParameter("@Status", Data.Status));
				cmd.Parameters.Add(new SqlParameter("@reply", Data.reply));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[tb_CustomerCare_Update]
		public void tb_CustomerCare_Update(tb_CustomerCareInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tb_CustomerCare_Update", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Id", Data.Id));
				cmd.Parameters.Add(new SqlParameter("@Email", Data.UserName));
				cmd.Parameters.Add(new SqlParameter("@Title", Data.Title));
				cmd.Parameters.Add(new SqlParameter("@Content", Data.Content));
				cmd.Parameters.Add(new SqlParameter("@Status", Data.Status));
				cmd.Parameters.Add(new SqlParameter("@reply", Data.reply));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[tb_CustomerCare_Delete]
		public void tb_CustomerCare_Delete(string Data)
		{
			using (var cmd = new SqlCommand("sp_tb_CustomerCare_Delete", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Id", Data));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion


        #region[tb_CustomerCare_GetByUserName]
        public DataTable tb_CustomerCare_GetByUserName(tb_CustomerCareInfo Data)
		{
            using (var cmd = new SqlCommand("tb_CustomerCare_GetByUserName", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@UserName", Data.UserName));
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
	}
}